from pathlib import Path

template = '''
function getResponse() {
	return {
		username: $USERNAME$,
		password: $PASSWORD$,
	}
}
'''

def run() -> bool:
    folder = Path(r'D:\TamperMonkeyComm')
    if not folder.exists():
        folder.mkdir()

    file = folder / 'YTU_Password.js'
    if file.exists():
        print('文件已经存在：', file)
        return False
    
    username = input('用户名: ')
    password = input('密码: ')
    js = template.replace('$USERNAME$', username).replace('$PASSWORD$', password)
    file.touch()
    file.write_text(js)
    print('文件已经生成：', file)
    return True

if __name__ == '__main__':
    run()
    input('按回车键退出')
